# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Ray Rashif <schiv@archlinux.org>
# Contributor: damir <damir@archlinux.org>

pkgname=fluidsynth
pkgver=2.2.3
pkgrel=1
pkgdesc="A real-time software synthesizer based on the SoundFont 2 specifications"
arch=('x86_64')
url="https://www.fluidsynth.org/"
license=('LGPL2.1')
groups=('pro-audio')
depends=('glibc' 'sdl2')
makedepends=('alsa-lib' 'cmake' 'dbus' 'doxygen' 'glib2' 'jack' 'ladspa'
'libinstpatch' 'libpulse' 'libsndfile' 'portaudio' 'readline' 'systemd-libs')
provides=('libfluidsynth.so' 'soundfont-synthesizer')
backup=("etc/conf.d/$pkgname")
source=("$pkgname-$pkgver.tar.gz::https://github.com/${pkgname}/${pkgname}/archive/v$pkgver.tar.gz")
sha512sums=('67f8da02714350cc0439fbdce763d00cb08d01301a6aaa3e2655e67935048b43e18968c9a52aa64c702b5e30ae2b2b4946f69e8be4af5889fa414c654d4eb13e')
b2sums=('0d08c67532392d32501a71f1e6fac6d55a0a0a607dae914106e1674df0a96869041530f75669193305a091ec40177e2925345df24d75a369c87e738ec1f4eb2e')

build() {
  cd "${pkgname}-${pkgver}"
  cmake -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_BUILD_TYPE='None' \
        -DFLUID_DAEMON_ENV_FILE=/etc/conf.d/fluidsynth \
        -Denable-ladspa=ON \
        -Denable-portaudio=ON \
        -DLIB_SUFFIX="" \
        -Wno-dev \
        -B build \
        -S .
  make -C build VERBOSE=1
}

check() {
  cd "${pkgname}-${pkgver}"
  make -C build -k check
}

package() {
  depends+=('libasound.so' 'libdbus-1.so' 'libglib-2.0.so' 'libgmodule-2.0.so'
  'libgobject-2.0.so' 'libinstpatch-1.0.so' 'libjack.so' 'libportaudio.so'
  'libpulse-simple.so' 'libreadline.so' 'libsndfile.so' 'libsystemd.so')
  cd "${pkgname}-${pkgver}"
  make -C build DESTDIR="$pkgdir" install
  # systemd user unit
  install -vDm 644 "build/${pkgname}.service" \
    -t "$pkgdir/usr/lib/systemd/user/"
  # system-wide configuration file
  install -vDm 644 "build/${pkgname}.conf" "${pkgdir}/etc/conf.d/${pkgname}"
  # docs
  install -vDm 644 {AUTHORS,ChangeLog,{CONTRIBUTING,README}.md,THANKS,TODO} \
    -t "${pkgdir}/usr/share/doc/${pkgname}"
}
